﻿@using XXS.Common.Paginate;
@model IPaginate<KTD.Web.Models.VD.AdvVD>
<style>
    .saveResult .layui-form-label {
        width: 120px;
    }
</style>

<div class="x-body" id="box">
    <div class="layui-row">
        <form class="layui-form ">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    @Html.TextBox("Query", null, new { @class = "layui-input", placeholder = "关键字" })
                    <input  type="hidden" id="type" name="type" value="@ViewBag.Type"/>
                </div>
                <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </div>
        </form>
    </div>

    <xblock style="height:50px;">
        <button class="layui-btn" id="addBtn"><i class="layui-icon"></i>添加</button>

        <span class="x-right" style="line-height:40px">共有数据：@Model.SourceCount 条</span>
    </xblock>

    <table class="layui-table">
        <thead>
            <tr>
                <th style="width:100px;">广告图片</th>
                <th>楼盘名称</th>
                <th>所属城市</th>
                <th>顺序</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.PageData)
            {
            <tr>
                <td><a title="预览" href="javascript:;" onclick="x_admin_show('预览','/Home/ImagePre?src=@item.thumb')"><image class="imagePre" src="@item.thumb"></image></a></td>
                <td>@item.advname</td>
                <td>@item.url</td>
                <td>@item.displayorder</td>
                <td>@item.enabled</td>
                <td class="td-manage">
                    <a title="编辑" onclick="update(this,'@item.Id')" href="javascript:;">
                        <i class="icon iconfont">
                            &#xe6ab;
                        </i>
                    </a>

                    <a title="删除" onclick="member_del(this,'@item.Id')" href="javascript:;">
                        <i class="layui-icon">&#xe640;</i>
                    </a>
                </td>
            </tr>
            }

        </tbody>
    </table>

    @{
        Html.RenderPartial("_paginate", Model);
    }



</div>


@section scripts{
    <script>
        /*删除*/
        function member_del(obj, id) {
            layer.confirm('确认要删除吗？', function (index) {
                 $.ajax({
                     url: '/Adv/Delete',
                        type: 'post',
                        data: {
                            Id:id,
                        },
                        dataType: 'json',
                        success: function (res) {
                            if (res.success) {

                               $(obj).parents("tr").remove();
                               layer.msg('已删除!', { icon: 1, time: 1000 });
                            }
                            else {
                                layer.msg('删除失败，' + res.msg, { icon: 2, time: 5000 });
                            }

                        }
                    });
                });
        }


        function update(obj, id) {
            var win = layer.open({
                type: 2,
                skin: 'layui-layer-rim', //加上边框
                area: ['420px', '500px'], //宽高
                content: "/Adv/Update/"+id //弹出编辑框
            });
        }
        $(function () {
            $("#addBtn").click(function () {
                var win = layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['420px', '500px'], //宽高
                    content: "/Adv/Create?Type="+"@ViewBag.Type" //弹出编辑框
                });
            });
        });

    </script>
}